package com.jdk8.parameter_03;

import java.util.ArrayList;
import java.util.List;

public class AppleSystem {

    public static void main(String[] args) {
        AppleQuery appleQuery = new AppleQuery();
        List<Apple> apples = appleQuery.applesData();
        AppleModel appleModel = new AppleModel();
        List<Apple> appleList = appleModel.filterApples("green", (String color, Apple apple) -> {
            if (color == null || color.isEmpty()) {
                return false;
            }
            return color.equals(apple.getColor()); }, apples);
        for (Apple apple : appleList) {
            System.out.println(apple);
        }

        System.out.println("-----------------------");

        ArrayList<String> strings = appleModel.prettyPrintApple(apples, (Apple apple) -> {
            String str = apple.getWeight() > 150.00 ? "heavy" : "light";
            return apple.getKinds() + " have " + apple.getWeight() + "g and is " + str;
        });
        for (String string : strings) {
            System.out.println(string);
        }
    }
}
